// DEMO5_1.CPP - A ultra minimal working COM example
// NOTE: not fully COM compliant

// INCLUDES //////////////////////////////////////////////////////////////////////////////////

#include "GPInclude.h"

// GUIDS /////////////////////////////////////////////////////////////////////////////////////

// these were all generated with GUIDGEN.EXE

// {B9B8ACE1-CE14-11d0-AE58-444553540000}
const IID IID_IX = 
{ 0xb9b8ace1, 0xce14, 0x11d0, { 0xae, 0x58, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };


// {B9B8ACE2-CE14-11d0-AE58-444553540000}
const IID IID_IY = 
{ 0xb9b8ace2, 0xce14, 0x11d0, { 0xae, 0x58, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };

// {B9B8ACE3-CE14-11d0-AE58-444553540000}
const IID IID_IZ = 
{ 0xb9b8ace3, 0xce14, 0x11d0, { 0xae, 0x58, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };


// INTERFACES ////////////////////////////////////////////////////////////////////////////////

// define the IX interface
interface IX: IUnknown
{

	virtual void __stdcall fx(void)=0;

}; 

// define the IY interface
interface IY: IUnknown
{

	virtual void __stdcall fy(void)=0;

}; 


// CLASSES AND COMPONENTS ///////////////////////////////////////////////////////////////////

// define the COM object
class CCOM_OBJECT :	public IX,
	public IY
{
public:

	CCOM_OBJECT() : ref_count(0) {}
	~CCOM_OBJECT() {}

private:

	virtual HRESULT __stdcall QueryInterface(const IID &iid, void **iface);
	virtual ULONG __stdcall AddRef();
	virtual ULONG __stdcall Release();

	virtual	void __stdcall fx(void) {std::cout << "Function fx has been called." << std::endl; }
	virtual void __stdcall fy(void) {std::cout << "Function fy has been called." << std::endl; }

	int ref_count;

};

void ComTest(void);